#include"common.h"

#define MTVEC 0x305
#define MEPC 0x341
#define MSTAUTS 0x300
#define MCAUSE 0x342
typedef void(*io_callback_t)(uint32_t, int, bool);
uint8_t* new_space(int size);

typedef struct {
  const char *name;
  // we treat ioaddr_t as paddr_t here
  paddr_t address;
	word_t date;
} CSR;

static inline int find_csr_by_addr(CSR *csrs,int size,paddr_t addr) {
  int i;
  for (i = 0; i < size; i ++) {
    if ((csrs + i)->address==addr) {
      return i;
    }
  }
  return -1;
}

word_t read_csr(paddr_t addr);
void write_csr(paddr_t addr,word_t date);
